# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=sqlitedict
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
         "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=1.4.1
pkgrel=1
pkgdesc="Persistent dict, backed by sqlite3 and pickle, multithread-safe (mingw-w64)"
arch=('any')
license=('BSD')
url="http://github.com/RaRe-Technologies/sqlitedict"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-nose"
              "${MINGW_PACKAGE_PREFIX}-python2-nose"
              "${MINGW_PACKAGE_PREFIX}-python3-coverage"
              "${MINGW_PACKAGE_PREFIX}-python2-coverage")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/RaRe-Technologies/sqlitedict/archive/${pkgver}.tar.gz")
sha256sums=('282093d116de6deafb0e0888bff71fad8046b702d77b1e73c53b87a901db7738')


prepare() {
  cp -a ${_realname}-${pkgver}{,-py2}
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}
  python3 setup.py build

  cd $srcdir/${_realname}-${pkgver}-py2
  python2 setup.py build
}

check() {
  cd ${srcdir}/${_realname}-${pkgver}
  nosetests-3.5

  cd ${srcdir}/${_realname}-${pkgver}-py2
  nosetests-2.7
}

package_python3-sqlitedict() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python3"
    "${MINGW_PACKAGE_PREFIX}-sqlite3"
  )

  cd ${srcdir}/${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
#  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-sqlitedict/LICENSE"
}

package_python2-sqlitedict() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python2"
    "${MINGW_PACKAGE_PREFIX}-sqlite3"
  )

  cd ${srcdir}/${_realname}-${pkgver}-py2
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
#  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-sqlitedict/LICENSE"
}

package_mingw-w64-i686-python2-sqlitedict() {
  package_python2-sqlitedict
}

package_mingw-w64-i686-python3-sqlitedict() {
  package_python3-sqlitedict
}

package_mingw-w64-x86_64-python2-sqlitedict() {
  package_python2-sqlitedict
}

package_mingw-w64-x86_64-python3-sqlitedict() {
  package_python3-sqlitedict
}

# vim:set ts=2 sw=2 et:
